<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../node_modules/vue/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <a v-bind:href="url"></a>
        <input :type="text">
        <input type="button" value="D" v-on:click="show()">

        <br>
        <br>
        <br>
        <label>
            <input type="checkbox" name="checkAll" v-model="checkAll" @change="changes"> 全选
        </label>

        <hr>

        <label v-for="(item, index) in hobbyList" :key="index">
            <input type="checkbox" name="item" :value="item" v-model="selected" @change="changes1"> {{item}}
        </label>

    
    </div>

    <script src="js/vue.js"></script>
    <script>
        new Vue({
            el: "#app",
            data: {
                text: "text",
                checkAll: false,
                selected: [],
                hobbyList: [
                    '吃饭',
                    '睡觉',
                    '打豆豆'
                ]
            },
            methods: {
                show() {
                    if (this.text == "text") {
                        this.text = "password"
                        return
                    }
                    this.text = "text"
                },
                changes() {
                    if (this.checkAll) {
                        this.selected = this.hobbyList;
                    }

                },
                changes1(){
                    if(this.selected.length==this.hobbyList.length){
                        this.checkAll=true;
                    }else{
                        this.checkAll=false;
                        
                    }
                }
            }
        });
    </script>
</body>

</html>